/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author usuario
 */
@Entity
@Table(name = "venta")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Venta.findAll", query = "SELECT v FROM Venta v"),
    @NamedQuery(name = "Venta.findByIdventa", query = "SELECT v FROM Venta v WHERE v.idventa = :idventa"),
    @NamedQuery(name = "Venta.findByFechaventa", query = "SELECT v FROM Venta v WHERE v.fechaventa = :fechaventa"),
    @NamedQuery(name = "Venta.findByVlrtotal", query = "SELECT v FROM Venta v WHERE v.vlrtotal = :vlrtotal"),
    @NamedQuery(name = "Venta.findBySaldoventa", query = "SELECT v FROM Venta v WHERE v.saldoventa = :saldoventa")})
public class Venta implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "idventa")
    private String idventa;
    @Basic(optional = false)
    @Column(name = "fechaventa")
    @Temporal(TemporalType.DATE)
    private Date fechaventa;
    @Basic(optional = false)
    @Column(name = "vlrtotal")
    private double vlrtotal;
    @Basic(optional = false)
    @Column(name = "saldoventa")
    private double saldoventa;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "venta")
    private Collection<Itemventa> itemventaCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "venta")
    private Collection<Pagocliente> pagoclienteCollection;
    @JoinColumn(name = "idempleado", referencedColumnName = "idempleado")
    @ManyToOne(optional = false)
    private Empleado idempleado;
    @JoinColumn(name = "idcliente", referencedColumnName = "idcliente")
    @ManyToOne(optional = false)
    private Cliente idcliente;

    public Venta() {
    }

    public Venta(String idventa) {
        this.idventa = idventa;
    }

    public Venta(String idventa, Date fechaventa, double vlrtotal, double saldoventa) {
        this.idventa = idventa;
        this.fechaventa = fechaventa;
        this.vlrtotal = vlrtotal;
        this.saldoventa = saldoventa;
    }

    public String getIdventa() {
        return idventa;
    }

    public void setIdventa(String idventa) {
        this.idventa = idventa;
    }

    public Date getFechaventa() {
        return fechaventa;
    }

    public void setFechaventa(Date fechaventa) {
        this.fechaventa = fechaventa;
    }

    public double getVlrtotal() {
        return vlrtotal;
    }

    public void setVlrtotal(double vlrtotal) {
        this.vlrtotal = vlrtotal;
    }

    public double getSaldoventa() {
        return saldoventa;
    }

    public void setSaldoventa(double saldoventa) {
        this.saldoventa = saldoventa;
    }

    @XmlTransient
    public Collection<Itemventa> getItemventaCollection() {
        return itemventaCollection;
    }

    public void setItemventaCollection(Collection<Itemventa> itemventaCollection) {
        this.itemventaCollection = itemventaCollection;
    }

    @XmlTransient
    public Collection<Pagocliente> getPagoclienteCollection() {
        return pagoclienteCollection;
    }

    public void setPagoclienteCollection(Collection<Pagocliente> pagoclienteCollection) {
        this.pagoclienteCollection = pagoclienteCollection;
    }

    public Empleado getIdempleado() {
        return idempleado;
    }

    public void setIdempleado(Empleado idempleado) {
        this.idempleado = idempleado;
    }

    public Cliente getIdcliente() {
        return idcliente;
    }

    public void setIdcliente(Cliente idcliente) {
        this.idcliente = idcliente;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idventa != null ? idventa.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Venta)) {
            return false;
        }
        Venta other = (Venta) object;
        if ((this.idventa == null && other.idventa != null) || (this.idventa != null && !this.idventa.equals(other.idventa))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modelo.Venta[ idventa=" + idventa + " ]";
    }
    
}
